1. Technical Field
The present invention relates to hypervisor-controlled virtual machines in general, and in particular to a method and apparatus for performing mapping within a data processing system having multiple virtual machines.
2. Description of Related Art
In recent years, with the development of virtualization technology, it has become possible to use a hypervisor to logically divide a data processing system (i.e., a single physical machine) into multiple virtual machines. Each of the virtual machines has its own partition, and the hypervisor enforces separation among different virtual machines such that one virtual machine is not able to access a memory space of another virtual machine. An operating system and/or application program within a virtual machine can be referred to as a guest partition. Each guest partition addresses its memory space via a logical address. When a guest partition needs to access its memory space, the hypervisor must convert the logical address of the memory space to a physical address of a memory device by way of a conversion table. As such, several guest partitions within a data processing system may be able to access the same logical address without interfering with each other.
In order to increase processing speed of certain tasks, some processors within a data processing system can offload those tasks to a hardware accelerator within the data processing system. For example, processors such as Power7® and PowerEN® are capable of calling a hardware accelerator via an ICSWX instruction. If a virtual machine executes the ICSWX instruction, the logical partition identifier (LPARID) of the virtual machine and the addresses at which parameters on the memory are arranged to be sent to the hardware accelerator. Afterwards, data are generally exchanged between a guest partition of the virtual machine and the hardware accelerator via a memory (or a cache). Moreover, when data are complicated, it is necessary to use a data structure, such as a linked list, a tree or the like, to arrange pointers to various areas of the memory to locate the data. In this case, the guest partition prepares the data structure and corresponding pointers for pointing at various logical addresses. Since the hardware accelerator requires a physical address in order to access the physical memory device, it is necessary to inform the hardware accelerator of the relationship between physical addresses and logical addresse. The process of informing the hardware accelerator of the relationship between physical addresses and logical addresses is referred to as mapping.
A hypervisor typically performs any required mapping. However, every time the hypervisor performs mapping, a context switch between the hypervisor and a guest partition must occur, which decreases system performance drastically. Consequently, it would be desirable to provide an improved method for a guest partition to convert a logical address to a physical address without decreasing system performance.